home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / xf2.3-p / xf2 / xf2.3 / elements / Scale < prev    next >
Encoding:
Text File  |  1993-11-20  |  6.5 KB  |  193 lines

  1. # Program: xf
  2. # Description: handle scale widgets
  3. #
  4. # $Header: Scale[2.3] Wed Mar 10 11:59:13 1993 garfield@garfield frozen $
  5.  
  6. global xfDefaultConf
  7. set xfDefaultConf(scale) 4
  8.  
  9. ##########
  10. # Procedure: XFAdd.Scale
  11. # Description: add a scale
  12. # Arguments: xfW - the widget
  13. #            xfName - a optional name
  14. #            xfType - add or config
  15. # Returns: none
  16. # Sideeffects: none
  17. ##########
  18. proc XFAdd.Scale {xfW xfName xfType} {
  19.   global xfStatus
  20.  
  21.   XFEditSetStatus "Inserting Scale..."
  22.   set xfName [XFMiscGetUniqueName $xfName scale]
  23.   if {"$xfStatus(path)" == "."} {
  24.     if {"$xfType" == "add"} {
  25.       scale .$xfName \
  26.         -relief raised \
  27.         -orient horizontal
  28.     } {
  29.       scale .$xfName
  30.     }
  31.  
  32.     XFMiscPositionWidget .$xfName
  33.     XFMiscBindWidgetTree .$xfName
  34.   } {
  35.     if {"$xfType" == "add"} {
  36.       scale $xfStatus(path).$xfName \
  37.         -relief raised \
  38.         -orient horizontal
  39.     } {
  40.       scale $xfStatus(path).$xfName
  41.     }
  42.  
  43.     XFMiscPositionWidget $xfStatus(path).$xfName
  44.     XFMiscBindWidgetTree $xfStatus(path).$xfName
  45.   }
  46.  
  47.   incr xfStatus(elementCounter)
  48.   XFEditSetPath $xfStatus(path)
  49.   XFEditSetStatus "Inserting Scale...done"
  50. }
  51.  
  52. ##########
  53. # Procedure: XFConfig.Scale4
  54. # Description: configure a scale
  55. # Arguments: xfW - the widget
  56. #            xfType - config type (add config)
  57. #            xfClass - the class we configure
  58. #            xfLeader - the leading window
  59. # Returns: none
  60. # Sideeffects: none
  61. ##########
  62. proc XFConfig.Scale4 {xfW xfType xfClass {xfLeader ""}} {
  63.   global xfConf
  64.   global xfStatus
  65.  
  66.   if {"$xfType" == "add"} {
  67.     set xfName scale$xfStatus(elementCounter)
  68.   } {
  69.     set xfName [XFMiscPathName $xfW]
  70.   }
  71.   XFEditSetStatus "Calling parameter setting for Scale..."
  72.  
  73.   # build widget structure
  74.   XFTmpltToplevel .xf${xfClass}Config4 400x620 \
  75.     "Scale parameters:[XFMiscPathTail $xfW]" $xfLeader
  76.  
  77.   XFElementInit $xfW .xf${xfClass}Config4 $xfType $xfClass  XFScaleSetScale4 \
  78.     parameters $xfName 4
  79.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass bg \
  80.     background Background "Background" XFScaleSetScale4
  81.   XFElementFont $xfW .xf${xfClass}Config4 $xfType $xfClass font \
  82.     font Font "Font" XFScaleSetScale4
  83.   if {$xfConf(kanji)} {
  84.     XFElementFont $xfW .xf${xfClass}Config4 $xfType $xfClass kanjifont \
  85.       kanjiFont KanjiFont "Kanji font" XFScaleSetScale4
  86.   }
  87.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass fg \
  88.     foreground Foreground "Foreground" XFScaleSetScale4
  89.   XFElementScale $xfW .xf${xfClass}Config4 $xfType $xfClass from \
  90.     from From "From" "int" 1000 XFScaleSetScale4
  91.   XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass label label \
  92.     Label "Label" XFScaleSetScale4 $xfName
  93.   XFElementScale $xfW .xf${xfClass}Config4 $xfType $xfClass length \
  94.     length Length "Length" "pixels" 1000 XFScaleSetScale4
  95.   XFElementOrient $xfW .xf${xfClass}Config4 $xfType $xfClass XFScaleSetScale4
  96.   XFElementBoolean $xfW .xf${xfClass}Config4 $xfType $xfClass showValue \
  97.     "Show value" XFScaleSetScale4
  98.   XFElementScale $xfW .xf${xfClass}Config4 $xfType $xfClass slength \
  99.     sliderLength SliderLength "Slider length" "pixels" 300 XFScaleSetScale4
  100.   XFElementScale $xfW .xf${xfClass}Config4 $xfType $xfClass to \
  101.     to To "To" "int" 5000 XFScaleSetScale4
  102.   XFElementScale $xfW .xf${xfClass}Config4 $xfType $xfClass width \
  103.     width Width "Width" "pixels" 200 XFScaleSetScale4
  104.   XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass command \
  105.     command Command "Command" XFScaleSetScale4
  106.  
  107.   if {"$xfType" == "add"} {
  108.     .xf${xfClass}Config4.params1.params2.label.label delete 0 end
  109.     .xf${xfClass}Config4.params1.params2.orient.horizontal select
  110.   }
  111.  
  112.   # save current parameter
  113.   if {$xfConf(kanji)} {
  114.     XFElementSave $xfW $xfClass {background command font kanjifont foreground from length orient showvalue sliderlength to width}
  115.   } {
  116.     XFElementSave $xfW $xfClass {background command font foreground from length orient showvalue sliderlength to width}
  117.   }
  118.  
  119.   # packing
  120.   pack append .xf${xfClass}Config4.params1 \
  121.               .xf${xfClass}Config4.params1.params2 {left fill expand}
  122.   pack append .xf${xfClass}Config4 \
  123.               .xf${xfClass}Config4.pathname {top fill frame center} \
  124.               .xf${xfClass}Config4.leave {bottom fill} \
  125.               .xf${xfClass}Config4.additional {bottom fill} \
  126.               .xf${xfClass}Config4.params1 {top fill expand}
  127.  
  128.   XFBindFormConnect .xf${xfClass}Config4.params1.params2 \
  129.     "XFScaleSetScale4 $xfW 0 $xfClass"
  130.  
  131.   XFEditSetStatus "Calling parameter setting for Scale...done"
  132. }
  133.  
  134. ##########
  135. # Procedure: XFScaleSetScale4
  136. # Description: set scale parameters
  137. # Arguments: xfW - the widget
  138. #            xfType - the type of setting (1 = set always, 0 = set
  139. #                     only if permanent apply is on)
  140. #            xfClass - the class we configure
  141. #            xfParam1 - ignored parameter
  142. # Returns: none
  143. # Sideeffects: none
  144. ##########
  145. proc XFScaleSetScale4 {xfW xfType xfClass {xfParam1 ""}} {
  146.   global xfConf
  147.   global xfMisc
  148.  
  149.   if {$xfType == 0 && !$xfConf(applyParameters)} {
  150.     return
  151.   }
  152.   if {"[info commands $xfW]" == ""} {
  153.     return
  154.   }
  155.   XFMiscSetSymbolicName $xfW \
  156.     [.xf${xfClass}Config4.params1.params2.symname.symname get]
  157.  
  158.   XFMiscSetResource $xfW background \
  159.     [.xf${xfClass}Config4.params1.params2.bg.bg get]
  160.   XFMiscSetResource $xfW command \
  161.     [.xf${xfClass}Config4.params1.params2.command.command get]
  162.   XFMiscSetResource $xfW font \
  163.     [.xf${xfClass}Config4.params1.params2.font.font get]
  164.   if {$xfConf(kanji)} {
  165.     XFMiscSetResource $xfW kanjifont \
  166.       [.xf${xfClass}Config4.params1.params2.kanjifont.kanjifont get]
  167.   }
  168.   XFMiscSetResource $xfW foreground \
  169.     [.xf${xfClass}Config4.params1.params2.fg.fg get]
  170.   if {[.xf${xfClass}Config4.params1.params2.to.to get] <
  171.       [.xf${xfClass}Config4.params1.params2.from.from get]} {
  172.     .xf${xfClass}Config4.params1.params2.to.to set \
  173.       [expr [.xf${xfClass}Config4.params1.params2.from.from get]+1]
  174.   }
  175.   XFMiscSetResource $xfW from \
  176.     [.xf${xfClass}Config4.params1.params2.from.from get]
  177.   XFMiscSetResource $xfW label \
  178.     [.xf${xfClass}Config4.params1.params2.label.label get]
  179.   XFMiscSetResource $xfW length \
  180.     [.xf${xfClass}Config4.params1.params2.length.length get]
  181.   XFMiscSetResource $xfW orient $xfMisc(orient)
  182.   XFMiscSetResource $xfW showvalue $xfMisc(showValue)
  183.   XFMiscSetResource $xfW sliderlength \
  184.     [.xf${xfClass}Config4.params1.params2.slength.slength get]
  185.   XFMiscSetResource $xfW to \
  186.     [.xf${xfClass}Config4.params1.params2.to.to get]
  187.   XFMiscSetResource $xfW width \
  188.     [.xf${xfClass}Config4.params1.params2.width.width get]
  189. }
  190.  
  191. # eof
  192.  
  193.